const { ccclass, property } = cc._decorator;

import { app } from '../../app';
import { menu } from '../../decorator';
import { viewKeyEnum } from '../../executor';
import baseButtonTouch from './base/baseButtonTouch'

@ccclass
@menu(__filename)
export default class touchHide extends baseButtonTouch {
    @property
    _uiName: string = viewKeyEnum[0] || '';
    @property({
        type: cc.Enum(viewKeyEnum)
    })
    get uiName(): number {
        const num = this._uiName ? viewKeyEnum[this._uiName] : 0;
        return typeof num === 'undefined' ? -1 : num;
    };
    set uiName(value) {
        this._uiName = viewKeyEnum[value];
    };

    @property
    customData: boolean = false;
    @property({
        visible(this: touchHide) {
            return this.customData;
        }
    })
    data: string = '';

    onLoad() {
        this.target.on(this.timeEvent, function () {
            viewKeyEnum[this.uiName] && app.manager.ui.show({
                name: viewKeyEnum[this.uiName] as any,
                data: this.customData ? { type: "clickShow", data: this.data } : undefined
            })
        }, this);
    }
}
